<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		
		<meta charset="utf-8" />
		<title></title>
		
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="stylesheet" href="static/css/bootstrap.min.css" />
		<link rel="stylesheet" href="static/css/bootstrap-responsive.min.css" />
		<link rel="stylesheet" href="static/css/font-awesome.min.css" />
		<!--[if IE 7]><link rel="stylesheet" href="css/font-awesome-ie7.min.css" /><![endif]-->
		<!--[if lt IE 9]><link rel="stylesheet" href="css/ace-ie.min.css" /><![endif]-->
		
		<link rel="stylesheet" href="static/css/ace.min.css" />
		<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
		<link rel="stylesheet" href="static/css/ace-skins.min.css" />
		<link rel="stylesheet" href="static/css/datepicker.css" /><!-- 日期框 -->
		<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
		<!--提示框-->
		<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript">
	
	$(window.parent.hangge());
	//保存
	function save() {
		if($("#version_name").val()==""){
			$("#version_name").tips({
				side:3,
	            msg:'输入版本名称',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#version_name").focus();
			return false;
		}
		
		if($("#version_code").val()==""){
			$("#version_code").tips({
				side:3,
	            msg:'输入版本号',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#version_code").focus();
			return false;
		}else{
			var version_code = $("#version_code").val();
			
			if(isNaN(version_code)){
				$("#version_code").tips({
					side:3,
		            msg:'版本号必须是数值',
		            bg:'#AE81FF',
		            time:3
		        });
				$("#version_code").focus();
				return false;
			}
		}
		
		if($("#url").val()==""){
			$("#url").tips({
				side:3,
	            msg:'输入下载地址',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#url").focus();
			return false;
		}
		
		if($("#description").val()==""){
			$("#description").tips({
				side:3,
	            msg:'输入更新说明',
	            bg:'#AE81FF',
	            time:2
	        });
			
			$("#description").focus();
			return false;
		}

		$("#form1").submit();
		$("#centerOfMainFrame").hide();
		$("#centerOfMainFrame2").show();
	}
	
	//删除文件
	function delP(tpurl,id){
		 if(confirm("确定要删除文件？")){
			$.ajax({
				type : "POST",
				url : "version/deltp/" + tpurl + "/" +id+ ".json",
				contentType:"application/json",  //发送至服务器的类型
				dataType : "json",     //预期服务器返回类型
				success: function(data){
					if(data.string=="success"){
						alert("删除成功!");
						document.location.reload();
					}
				}
			})
		} 
	}
</script>
	</head>
<body>
		<form action="version/editVersion.do" name="form1" id="form1"  method="post" enctype="multipart/form-data">
		<input type="hidden" name="version_id" id="version_id" value="${version.version_id}"/>
			<div id="centerOfMainFrame">
			<table>
				<tr>
					<td>版本名称:</td>
					<td><input type="text" name="version_name" id="version_name"
						placeholder="这里输入版本名称" title="版本名称" value="${version.version_name }"/></td>
				</tr>
				<tr>
					<td>版本号:</td>
					<td><input type="text" name="version_code" id="version_code"
						placeholder="这里输入版本号" title="版本号" value="${version.version_code }"/></td>
				</tr>
				<c:if test="${version.type == 2 }">
					<tr>
						<td>下载地址:</td>
						<td><input type="text" name="url" id="url"
							placeholder="这里输入下载地址" title="下载地址" value="${version.url }"/></td>
					</tr>
				</c:if>
				<c:if test="${version.type == 1 }">
					<tr>
						<td>下载地址:</td>
						<td><input type="text" name="url2" id="url2"
							placeholder="这里输入下载地址" title="下载地址" value="${version.url2 }"/></td>
					</tr>
				</c:if>
				<tr>
					<td>下载地址3:</td>
					<td><input type="text" name="url3" id="url3"
						placeholder="这里输入下载地址3" title="下载地址3" value="${version.url3 }"/></td>
				</tr>
				<c:if test="${version.type == 1 }">
					<c:if test="${version.url == '' || version.url == null}">
						<tr>
							<td>上传文件:</td>
							<td><input type="file" id="url_android" name="url_android"/></td>
						</tr>
					</c:if>
					<c:if test="${version.url != null }">
						<tr>
							<td>上传文件:</td>
							<td>
								${version.url }
								<input type="button" class="btn btn-mini btn-danger" value="删除" onclick="delP('${version.url}','${version.version_id }');" />
								<input type="hidden" name="androidurlhidden" id="androidurlhidden" value="${version.url }"/>
							</td>
						</tr>
					</c:if>
				</c:if>
				<tr>
					<td>版本状态:</td>
					<td>
						<select id="isactive" name="isactive" title="版本状态">
							<option value="1" <c:if test="${version.isactive == 1 }">selected</c:if> >上线</option>
							<option value="0" <c:if test="${version.isactive == 0 }">selected</c:if> >下线</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>操作系统:</td>
					<td>
						<select id="type" name="type" title="操作系统" disabled="disabled">
							<option value="1" <c:if test="${version.type == 1 }">selected</c:if> >ANDROID</option>
							<option value="2" <c:if test="${version.type == 2 }">selected</c:if> >IOS</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>是否强制升级:</td>
					<td>
						<select id="force_upgrade" name="force_upgrade" title="是否强制升级">
							<option value="1" <c:if test="${version.force_upgrade == 1 }">selected</c:if> >强制</option>
							<option value="0" <c:if test="${version.force_upgrade == 0 }">selected</c:if> >不强制</option>
						</select>	
					</td>
				</tr>
				<tr>
					<td>更新说明:</td>
					<td>
						<textarea style="width:93%;height:290px" name="description" id="description">${version.description }</textarea>
					</td>
				</tr>
				<tr>
					<td>发布日期:</td>
					<td>
						<input class="span10 date-picker" name="release_date" id="release_date" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" placeholder="发布日期" title="发布日期" value="${version.release_date_show}"/>
					</td>
				</tr>
				<tr>
					<td style="text-align: center;"><a
						class="btn btn-mini btn-primary" onclick="save();">保存</a> <a
						class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
					</td>
				</tr>
			</table>
		</div>
		</form>
	
	<div id="centerOfMainFrame2" class="center" style="display:none"><img src="static/images/jzx.gif"  style="width: 50px;" /><br/><h4 class="lighter block green"></h4></div>
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		
		<script type="text/javascript">
		$(top.hangge());
		$(function() {
			
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
		});
		
		//上传
		$('#url_android').ace_file_input({
			no_file:'请选择文件 ...',
			btn_choose:'选择',
			btn_change:'更改',
			droppable:false,
			onchange:null,
			thumbnail:false //| true | large
			//whitelist:'gif|png|jpg|jpeg'
			//blacklist:'exe|php'
			//onchange:''
			//
		});
		</script>
</body>
</html>
